home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
network
/
samba
/
patches
/
samba-1.020
/
samba-1
Wrap
Text File
|
1995-12-05
|
37KB
|
1,316 lines
diff -u -r --new-file last-version/README samba-1.9.15p6/README
--- last-version/README Sat Nov 11 13:08:13 1995
+++ samba-1.9.15p6/README Mon Dec 4 00:35:44 1995
@@ -49,7 +49,7 @@
something else.
Andrew Tridgell
-Andrew.Tridgell@anu.edu.au
+Email: samba-bugs@anu.edu.au
3 Ballow Crescent
Macgregor, A.C.T.
diff -u -r --new-file last-version/docs/security_level.txt samba-1.9.15p6/docs/security_level.txt
--- last-version/docs/security_level.txt Thu Jan 1 10:00:00 1970
+++ samba-1.9.15p6/docs/security_level.txt Tue Dec 5 14:52:56 1995
@@ -0,0 +1,78 @@
+Description of SMB security levels.
+----------------------------------
+
+
+A SMB server tells the client at startup what "security level" it is
+running. There are two options "share level" and "user level". Which
+of these two the client receives affects the way the client then tries
+to authenticate itself. It does not directly affect (to any great
+extent) the way the Samba server does security. I know this is
+strange, but it fits in with the client/server aproach of SMB. In SMB
+everything is initiated and controlled by the client, and the server
+can only tell the client what is available and whether an action is
+allowed.
+
+I'll describe user level security first, as its simpler. In user level
+security the client will send a "session setup" command directly after
+the protocol negotiation. This contains a username and password. The
+server can either accept or reject that username/password
+combination. Note that at this stage the server has no idea what
+share the client will eventually try to connect to, so it can't base
+the "accept/reject" on anything other than:
+
+- the username/password
+- the machine that the client is coming from
+
+If the server accepts the username/password then the client expects to
+be able to mount any share (using a "tree connection") without
+specifying a password. It expects that all access rights will be as
+the username/password specified in the "session setup".
+
+It is also possible for a client to send multiple "sesion setup"
+requests. When the server responds it gives the client a "uid" to use
+as an authentication tag for that username/password. The client can
+maintain multiple authentication contexts in this way (WinDD is an
+example of an application that does this)
+
+
+Ok, now for share level security. In share level security (the default
+with samba) the client authenticates itself separately for each
+share. It will send a password along with each "tree connection"
+(share mount). It does not explicitly send a username with this
+operation. The client is expecting a password to be assciated with
+each share, independent of the user. This means that samba has to work
+out what username the client probably wants to use. It is never
+explicitly sent the username. A "real" SMB server like NT actually
+associates passwords directly with shares in share level security, but
+samba always uses the unix authentication scheme where it is a
+username/password that is authenticated, not a "share/password".
+
+Many clients send a "session setup" even if the server is in share
+level security. They normally send a valid username but no
+password. Samba records this username is a list of "possible
+usernames". When the client then does a "tree connection" it also adds
+to this list the name of the share they try to connect to (useful for
+home directories) and any users listed in the "user =" smb.conf
+line. The password is then checked in turn against these "possible
+usernames". If a match is found then the client is authenticated as
+that user.
+
+Finally "server level" security. In server level security the samba
+server reports to the client that it is in user level security. The
+client then does a "session setup" as described earlier. The samba
+server takes the username/password that the client sends and attempts
+to login to the "password server" by sending exactly the same
+username/password that it got from the client. If that server is in
+user level security and accepts the password then samba accepts the
+clients connection. This allows the samba server to use another SMB
+server as the "password server".
+
+You should also note that at the very start of all this, where the
+server tells the client what security level it is in, it also tells
+the client if it supports encryption. If it does then it supplies the
+client with a random "cryptkey". The client will then send all
+passwords in encrypted form. You have to compile samba with encryption
+enabled to support this feature, and you have to maintain a separate
+smbpasswd file with SMB style encrypted passwords. It is
+cryptographically impossible to translate from unix style encryption
+to SMB style encryption.
diff -u -r --new-file last-version/source/Makefile samba-1.9.15p6/source/Makefile
--- last-version/source/Makefile Sun Dec 3 18:57:00 1995
+++ samba-1.9.15p6/source/Makefile Mon Dec 4 10:50:41 1995
@@ -412,6 +412,12 @@
# FLAGSM = -DSOLARIS -DSHADOW_PWD -DBSD_COMP
# LIBSM = -lsocket -lnsl
+# This is for QNX 4.22
+# Contributed by eldo@invisa.satlink.net (Eldo Loguzzo)
+# FLAGSM = -DQNX -DGUEST_SESSSETUP=1
+# LIBSM =
+
+
######################################################################
# DON'T EDIT BELOW THIS LINE
diff -u -r --new-file last-version/source/change-log samba-1.9.15p6/source/change-log
--- last-version/source/change-log Sun Dec 3 21:56:45 1995
+++ samba-1.9.15p6/source/change-log Tue Dec 5 15:52:16 1995
@@ -1721,11 +1721,23 @@
- partially documented the "character set" option
- changed default for MAXDIR to 64
- changed default DPTR idle time to 120
+ - released p5
+ - QNX patches from eldo@invisa.satlink.net (Eldo Loguzzo)
+ - made nmbd use the "max log size" option and changed log handling
+ code a bit
+ - sunos patches, remote protocol (%R) addition and arch detection
+ changes to stop compiler warning from Timothy Hunt <tim@fsg.com>
+ - fixed become_user() bug that led to incorrect permissions in
+ some situations.
==========
todo:
+nmbd needs to keep browse list uptodate by talking to the master if it loses
+an election as others may still think its a valid backup and use it to get
+lists.
+
leftover lock files can end up belonging to non-smbd processes after a reboot.
hosts allow in nmbd
@@ -1775,6 +1787,8 @@
reverse mangled maps, so (*.html *.htm) works for new files.
install problems with w95. could be some sort of race?
+
+more efficient Files[] structure to handle thousands of open files
lpd stuff:
Tony Aiuto (tony@ics.com)
diff -u -r --new-file last-version/source/client.c samba-1.9.15p6/source/client.c
--- last-version/source/client.c Sun Dec 3 16:41:44 1995
+++ samba-1.9.15p6/source/client.c Mon Dec 4 11:47:53 1995
@@ -1350,8 +1350,6 @@
exit(1);
}
- log_in(inbuf,4);
-
/* Even though this is not an smb message, smb_len
returns the generic length of an smb message */
datalen = smb_len(inbuf);
@@ -1376,8 +1374,6 @@
DEBUG(0,("Failed to read data in readbraw\n"));
exit(1);
}
- log_in(inbuf,datalen);
-
dataptr = inbuf;
}
break;
@@ -4197,18 +4193,6 @@
DEBUG(3,("%s client started (version %s)\n",timestring(),VERSION));
-
- if (DEBUGLEVEL > 100)
- {
- extern FILE *login,*logout;
- pstring fname;
- sprintf(fname,"%s.in",debugf);
- login = fopen(fname,"w");
- if (login) chmod(fname,0600);
- sprintf(fname,"%s.out",debugf);
- logout = fopen(fname,"w");
- if (logout) chmod(fname,0600);
- }
get_myname(*myname?NULL:myname,&myip);
strupper(myname);
diff -u -r --new-file last-version/source/clitar.c samba-1.9.15p6/source/clitar.c
--- last-version/source/clitar.c Thu Nov 30 09:35:34 1995
+++ samba-1.9.15p6/source/clitar.c Mon Dec 4 11:47:51 1995
@@ -601,8 +601,6 @@
exit(1);
}
- log_in(inbuf,4);
-
/* Even though this is not an smb message, smb_len
returns the generic length of an smb message */
datalen = smb_len(inbuf);
@@ -627,8 +625,6 @@
DEBUG(0,("Failed to read data in readbraw\n"));
exit(1);
}
- log_in(inbuf,datalen);
-
dataptr = inbuf;
}
break;
diff -u -r --new-file last-version/source/getsmbpass.c samba-1.9.15p6/source/getsmbpass.c
--- last-version/source/getsmbpass.c Wed Nov 22 21:55:33 1995
+++ samba-1.9.15p6/source/getsmbpass.c Tue Dec 5 13:08:45 1995
@@ -52,7 +52,8 @@
return ioctl(fd, TCSETS, t);
}
-#elif BSD_TERMIO
+#else /* SYSV_TERMIO */
+#ifdef BSD_TERMIO
/* BSD TERMIO HANDLING */
@@ -66,6 +67,10 @@
#define TCSAFLUSH 1
#endif
+#ifndef TCSANOW
+#define TCSANOW 0
+#endif
+
int tcgetattr(int fd, struct sgttyb *t)
{
return ioctl(fd, TIOCGETP, (char *)t);
@@ -76,7 +81,7 @@
return ioctl(fd, TIOCSETP, (char *)t);
}
-#else
+#else /* BSD_TERMIO */
/* POSIX TERMIO HANDLING */
#define ECHO_IS_ON(t) ((t).c_lflag & ECHO)
@@ -84,7 +89,8 @@
#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO)
static struct termios t;
-#endif
+#endif /* BSD_TERMIO */
+#endif /* SYSV_TERMIO */
char *
getsmbpass(char *prompt)
diff -u -r --new-file last-version/source/includes.h samba-1.9.15p6/source/includes.h
--- last-version/source/includes.h Thu Nov 23 11:03:29 1995
+++ samba-1.9.15p6/source/includes.h Tue Dec 5 13:08:46 1995
@@ -80,6 +80,15 @@
#define NO_RESOURCEH
#endif
+#ifdef QNX
+#define NO_RESOURCEH
+#define NO_SYSMOUNTH
+#define USE_MMAP 1
+#ifdef __386__
+ #define __i386__
+#endif
+#endif
+
#if (defined(SHADOW_PWD)||defined(OSF1_ENH_SEC)||defined(SecureWare)||defined(PWDAUTH))
#define PASSWORD_LENGTH 16
#endif
@@ -221,7 +230,7 @@
#include <errno.h>
#include <sys/wait.h>
#include <signal.h>
-#include <termios.h>
+/* #include <termios.h> */
#ifdef sun386
#define NO_STRFTIME
#define NO_UTIMBUF
@@ -232,6 +241,7 @@
#define NO_STRERROR
#endif
#define REPLACE_GETPASS
+#define BSD_TERMIO
#endif
@@ -759,6 +769,24 @@
#define STATFS4
#define USE_GETCWD
#endif
+
+#ifdef QNX
+#define STATFS4
+#include <sys/statfs.h>
+#include <sys/select.h>
+#include <signal.h>
+#include <sys/dir.h>
+#define SIGNAL_CAST (void (*)())
+#define USE_WAITPID
+#define NO_INITGROUPS
+#define NO_SETGROUPS
+#define HAVE_TIMEZONE
+#define USE_GETCWD
+#define USE_SETSID
+#define HAVE_FCNTL_LOCK 1
+#define DEFAULT_PRINTING PRINT_QNX
+#endif
+
/*******************************************************************
diff -u -r --new-file last-version/source/loadparm.c samba-1.9.15p6/source/loadparm.c
--- last-version/source/loadparm.c Sun Dec 3 00:17:01 1995
+++ samba-1.9.15p6/source/loadparm.c Tue Dec 5 15:05:25 1995
@@ -597,6 +597,14 @@
string_initial(&sDefault.szLprmcommand,"cancel %p-%j");
string_initial(&sDefault.szPrintcommand,"lp -c -d%p %s; rm %s");
break;
+
+ case PRINT_QNX:
+ string_initial(&sDefault.szLpqcommand,"lpq -P%p");
+ string_initial(&sDefault.szLprmcommand,"lprm -P%p %j");
+ string_initial(&sDefault.szPrintcommand,"lp -r -P%p %s");
+ break;
+
+
}
}
@@ -1266,6 +1274,8 @@
*val = PRINT_HPUX;
else if (strequal(pszParmValue,"bsd"))
*val = PRINT_BSD;
+ else if (strequal(pszParmValue,"qnx"))
+ *val = PRINT_QNX;
return(True);
}
@@ -1298,7 +1308,7 @@
if (file_exist(fname,NULL))
return(pm_process(fname, do_section, do_parameter));
- DEBUG(1,("Can't find include file %s\n",fname));
+ DEBUG(2,("Can't find include file %s\n",fname));
return(False);
}
diff -u -r --new-file last-version/source/nameserv.c samba-1.9.15p6/source/nameserv.c
--- last-version/source/nameserv.c Sat Dec 2 19:28:23 1995
+++ samba-1.9.15p6/source/nameserv.c Mon Dec 4 11:48:17 1995
@@ -2080,12 +2080,12 @@
TimeInit();
+ strcpy(debugf,NMBLOGFILE);
+
setup_logging(argv[0],False);
charset_initialise();
- strcpy(debugf,NMBLOGFILE);
-
#ifdef LMHOSTSFILE
strcpy(host_file,LMHOSTSFILE);
#endif
@@ -2159,17 +2159,6 @@
usage(argv[0]);
break;
}
-
-
- if (DEBUGLEVEL > 10)
- {
- extern FILE *login,*logout;
- pstring fname;
- sprintf(fname,"%s.in",debugf);
- login = fopen(fname,"w");
- sprintf(fname,"%s.out",debugf);
- logout = fopen(fname,"w");
- }
DEBUG(1,("%s netbios nameserver version %s started\n",timestring(),VERSION));
DEBUG(1,("Copyright Andrew Tridgell 1994\n"));
diff -u -r --new-file last-version/source/nmblib.c samba-1.9.15p6/source/nmblib.c
--- last-version/source/nmblib.c Wed Nov 22 18:42:17 1995
+++ samba-1.9.15p6/source/nmblib.c Mon Dec 4 16:51:42 1995
@@ -629,10 +629,10 @@
p += 16;
if (p[0] & 0x80) strcat(flags,"<GROUP> ");
- if (p[0] & 0x60 == 0) strcat(flags,"B ");
- if (p[0] & 0x60 == 1) strcat(flags,"P ");
- if (p[0] & 0x60 == 2) strcat(flags,"M ");
- if (p[0] & 0x60 == 3) strcat(flags,"_ ");
+ if ((p[0] & 0x60) == 0) strcat(flags,"B ");
+ if ((p[0] & 0x60) == 1) strcat(flags,"P ");
+ if ((p[0] & 0x60) == 2) strcat(flags,"M ");
+ if ((p[0] & 0x60) == 3) strcat(flags,"_ ");
if (p[0] & 0x10) strcat(flags,"<DEREGISTERING> ");
if (p[0] & 0x08) strcat(flags,"<CONFLICT> ");
if (p[0] & 0x04) strcat(flags,"<ACTIVE> ");
diff -u -r --new-file last-version/source/printing.c samba-1.9.15p6/source/printing.c
--- last-version/source/printing.c Sun Dec 3 19:28:08 1995
+++ samba-1.9.15p6/source/printing.c Mon Dec 4 10:49:03 1995
@@ -494,7 +494,69 @@
return(True);
}
+/****************************************************************************
+parse a lpq line
+
+here is an example of lpq output under qnx
+Spooler: /qnx/spooler, on node 1
+Printer: txt (ready)
+0000: root [job #1 ] active 1146 bytes /etc/profile
+0001: root [job #2 ] ready 2378 bytes /etc/install
+0002: root [job #3 ] ready 1146 bytes -- standard input --
+****************************************************************************/
+static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
+{
+ string tok[7];
+ int count=0;
+
+ DEBUG(0,("antes [%s]\n", line));
+
+ /* handle the case of "-- standard input --" as a filename */
+ string_sub(line,"standard input","STDIN");
+ DEBUG(0,("despues [%s]\n", line));
+ string_sub(line,"-- ","\"");
+ string_sub(line," --","\"");
+ DEBUG(0,("despues 1 [%s]\n", line));
+
+ string_sub(line,"[job #","");
+ string_sub(line,"]","");
+ DEBUG(0,("despues 2 [%s]\n", line));
+
+
+
+ for (count=0; count<7 && next_token(&line,tok[count],NULL); count++) ;
+ /* we must get 7 tokens */
+ if (count < 7)
+ return(False);
+
+ /* the 3rd and 5th columns must be integer */
+ if (!isdigit(*tok[2]) || !isdigit(*tok[4])) return(False);
+
+ /* only take the last part of the filename */
+ {
+ string tmp;
+ char *p = strrchr(tok[6],'/');
+ if (p)
+ {
+ strcpy(tmp,p+1);
+ strcpy(tok[6],tmp);
+ }
+ }
+
+
+ buf->job = atoi(tok[2]);
+ buf->size = atoi(tok[4]);
+ buf->status = strequal(tok[3],"active")?LPQ_PRINTING:LPQ_QUEUED;
+ buf->priority = 0;
+ buf->time = time(NULL);
+ StrnCpy(buf->user,tok[1],sizeof(buf->user)-1);
+ StrnCpy(buf->file,tok[6],sizeof(buf->file)-1);
+ return(True);
+}
+
+
+
char *stat0_strings[] = { "enabled", "online", "idle", "no entries", "free", "ready", NULL };
char *stat1_strings[] = { "offline", "disabled", "down", "off", "waiting", "no daemon", NULL };
char *stat2_strings[] = { "jam", "paper", "error", "responding", "not accepting", "not running", "turned off", NULL };
@@ -518,6 +580,9 @@
break;
case PRINT_HPUX:
ret = parse_lpq_hpux(line,buf,first);
+ break;
+ case PRINT_QNX:
+ ret = parse_lpq_qnx(line,buf,first);
break;
default:
ret = parse_lpq_bsd(line,buf,first);
diff -u -r --new-file last-version/source/server.c samba-1.9.15p6/source/server.c
--- last-version/source/server.c Sun Dec 3 19:26:05 1995
+++ samba-1.9.15p6/source/server.c Tue Dec 5 15:57:11 1995
@@ -30,8 +30,6 @@
extern pstring debugf;
extern pstring sesssetup_user;
-BOOL append_log = True;
-
char *InBuffer = NULL;
char *OutBuffer = NULL;
char *last_inbuf = NULL;
@@ -42,7 +40,9 @@
BOOL share_mode_pending = False;
/* have I done a become_user? */
-int done_become_user = -1;
+static struct {
+ int cnum, uid;
+} last_user;
/* the last message the was processed */
int last_message = -1;
@@ -1343,13 +1343,8 @@
}
}
- if (flags == O_RDONLY) {
- /* when opening read only don't allow create and trunc bits */
- flags2 &= ~(O_TRUNC | O_CREAT);
- }
-
-
- DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X\n",flags,flags2));
+ DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X mode=0%o\n",
+ flags,flags2,mode));
open_file(fnum,cnum,fname,flags|(flags2&~(O_TRUNC)),mode);
if (!Files[fnum].open && flags==O_RDWR && errno!=ENOENT && fcbopen) {
@@ -1387,7 +1382,7 @@
if (!share_pid)
share_mode_pending = True;
- if (flags2&O_TRUNC)
+ if ((flags2&O_TRUNC) && file_existed)
truncate_unless_locked(fnum,cnum);
}
}
@@ -1633,7 +1628,7 @@
if (!ret)
DEBUG(1,("Failed to become guest. Invalid guest account?\n"));
- done_become_user = -2;
+ last_user.cnum = -2;
return(ret);
}
@@ -1664,11 +1659,19 @@
****************************************************************************/
BOOL become_user(int cnum, int uid)
{
+ int new_umask;
user_struct *vuser;
int snum,gid;
int ngroups;
gid_t *groups;
+ if (last_user.cnum == cnum && last_user.uid == uid) {
+ DEBUG(4,("Skipping become_user - already user\n"));
+ return(True);
+ }
+
+ unbecome_user();
+
if (!OPEN_CNUM(cnum)) {
DEBUG(2,("Connection %d not open\n",cnum));
return(False);
@@ -1698,14 +1701,6 @@
ngroups = vuser->user_ngroups;
}
- if (done_become_user == uid) {
- DEBUG(4,("Skipping become_user - already user\n"));
- return(True);
- }
-
- if (done_become_user != -1)
- unbecome_user();
-
if (initial_uid == 0)
{
if (!become_gid(gid)) return(False);
@@ -1723,12 +1718,14 @@
return(False);
}
- old_umask = umask(0777 & ~(CREATE_MODE(cnum)));
+ new_umask = 0777 & ~CREATE_MODE(cnum);
+ old_umask = umask(new_umask);
- done_become_user = uid;
+ last_user.cnum = cnum;
+ last_user.uid = uid;
- DEBUG(5,("become_user uid=(%d,%d) gid=(%d,%d)\n",
- getuid(),geteuid(),getgid(),getegid()));
+ DEBUG(5,("become_user uid=(%d,%d) gid=(%d,%d) new_umask=0%o\n",
+ getuid(),geteuid(),getgid(),getegid(),new_umask));
return(True);
}
@@ -1738,11 +1735,11 @@
****************************************************************************/
BOOL unbecome_user(void )
{
- ChDir(OriginalDir);
-
- if (done_become_user == -1)
+ if (last_user.cnum == -1)
return(False);
+ ChDir(OriginalDir);
+
umask(old_umask);
if (initial_uid == 0)
@@ -1781,7 +1778,7 @@
DEBUG(5,("unbecome_user now uid=(%d,%d) gid=(%d,%d)\n",
getuid(),geteuid(),getgid(),getegid()));
- done_become_user = -1;
+ last_user.cnum = -1;
return(True);
}
@@ -2115,103 +2112,6 @@
return True;
}
-/****************************************************************************
-reopen the log files
-****************************************************************************/
-void reopen_logs(void)
-{
- extern FILE *dbf;
- extern FILE *login,*logout;
- pstring fname;
- if (DEBUGLEVEL > 100)
- {
- if (!login)
- {
- sprintf(fname,"%s.in",debugf);
- login = fopen(fname,"w");
- if (login) chmod(fname,0600);
- }
- if (!logout)
- {
- sprintf(fname,"%s.out",debugf);
- logout = fopen(fname,"w");
- if (logout) chmod(fname,0600);
- }
- }
- else
- {
- if (login)
- {
- fclose(login);
- login = NULL;
- }
- if (logout)
- {
- fclose(logout);
- logout = NULL;
- }
- }
-
-
- if (DEBUGLEVEL > 0)
- {
- strcpy(fname,debugf);
- if (lp_loaded() && (*lp_logfile()))
- strcpy(fname,lp_logfile());
-
- if (!strcsequal(fname,debugf) || !dbf || !file_exist(debugf,NULL))
- {
- strcpy(debugf,fname);
- if (dbf) fclose(dbf);
- if (append_log)
- dbf = fopen(debugf,"a");
- else
- dbf = fopen(debugf,"w");
- if (dbf) setbuf(dbf,NULL);
- }
- }
- else
- {
- if (dbf)
- {
- fclose(dbf);
- dbf = NULL;
- }
- }
-}
-
-
-
-/****************************************************************************
-check the size of the log file
-****************************************************************************/
-static void check_log_size(void)
-{
- extern FILE *dbf;
- int maxlog = lp_max_log_size() * 1024;
-
- if (dbf && maxlog > 0)
- {
- struct stat st;
-
- if (fstat(fileno(dbf),&st) != 0) return;
-
- if (st.st_size > maxlog)
- {
- fclose(dbf); dbf = NULL;
- reopen_logs();
- if (dbf && file_size(debugf) > maxlog)
- {
- pstring name;
- fclose(dbf); dbf = NULL;
- sprintf(name,"%s.old",debugf);
- sys_rename(debugf,name);
- reopen_logs();
- }
- }
- }
-}
-
/****************************************************************************
check if a snum is in use
@@ -2632,7 +2532,6 @@
/* we've finished with the sensitive stuff */
unbecome_user();
-
{
extern struct from_host Client_info;
DEBUG(IS_IPC(cnum)?3:1,("%s %s (%s) connect to service %s as user %s (uid=%d,gid=%d) (pid %d)\n",
@@ -2697,26 +2596,6 @@
}
-/* List of supported protocols, most desired first */
-struct {
- char *proto_name;
- int (*proto_reply_fn)(char *);
- int protocol_level;
-} supported_protocols[] = {
- {"NT LANMAN 1.0", reply_nt1 , PROTOCOL_NT1},
- {"NT LM 0.12", reply_nt1 , PROTOCOL_NT1},
- {"LM1.2X002", reply_lanman2 , PROTOCOL_LANMAN2},
- {"Samba", reply_lanman2 , PROTOCOL_LANMAN2},
- {"DOS LM1.2X002", reply_lanman2 , PROTOCOL_LANMAN2},
- {"LANMAN1.0", reply_lanman1 , PROTOCOL_LANMAN1},
- {"MICROSOFT NETWORKS 3.0", reply_lanman1 , PROTOCOL_LANMAN1},
- {"MICROSOFT NETWORKS 1.03",reply_coreplus,PROTOCOL_COREPLUS},/* core+ protocol */
- {"PC NETWORK PROGRAM 1.0", reply_corep, PROTOCOL_CORE}, /* core protocol */
- {NULL,NULL},
-};
-
-
-
/****************************************************************************
reply for the core protocol
****************************************************************************/
@@ -2915,6 +2794,55 @@
protocol [LANMAN2.1]
*/
+/*
+ * Modified to recognize the architecture of the remote machine better.
+ *
+ * This appears to be the matrix of which protocol is used by which
+ * MS product.
+ Protocol WfWg Win95 WinNT OS/2
+ PC NETWORK PROGRAM 1.0 1 1 1 1
+ XENIX CORE 2 2
+ MICROSOFT NETWORKS 3.0 2 2
+ DOS LM1.2X002 3 3
+ MICROSOFT NETWORKS 1.03 3
+ DOS LANMAN2.1 4 4
+ LANMAN1.0 4 3
+ Windows for Workgroups 3.1a 5 5 5
+ LM1.2X002 6 4
+ LANMAN2.1 7 5
+ NT LM 0.12 6 8
+ *
+ * tim@fsg.com 09/29/95
+ */
+
+#define ARCH_WFWG 0x3 /* This is a fudge because WfWg is like Win95 */
+#define ARCH_WIN95 0x2
+#define ARCH_OS2 0xC /* Again OS/2 is like NT */
+#define ARCH_WINNT 0x8
+#define ARCH_SAMBA 0x10
+
+#define ARCH_ALL 0x1F
+
+/* List of supported protocols, most desired first */
+struct {
+ char *proto_name;
+ char *short_name;
+ int (*proto_reply_fn)(char *);
+ int protocol_level;
+} supported_protocols[] = {
+ {"NT LANMAN 1.0", "NT1", reply_nt1, PROTOCOL_NT1},
+ {"NT LM 0.12", "NT1", reply_nt1, PROTOCOL_NT1},
+ {"LM1.2X002", "LANMAN2", reply_lanman2, PROTOCOL_LANMAN2},
+ {"Samba", "LANMAN2", reply_lanman2, PROTOCOL_LANMAN2},
+ {"DOS LM1.2X002", "LANMAN2", reply_lanman2, PROTOCOL_LANMAN2},
+ {"LANMAN1.0", "LANMAN1", reply_lanman1, PROTOCOL_LANMAN1},
+ {"MICROSOFT NETWORKS 3.0", "LANMAN1", reply_lanman1, PROTOCOL_LANMAN1},
+ {"MICROSOFT NETWORKS 1.03", "COREPLUS", reply_coreplus, PROTOCOL_COREPLUS},
+ {"PC NETWORK PROGRAM 1.0", "CORE", reply_corep, PROTOCOL_CORE},
+ {NULL,NULL},
+};
+
+
/****************************************************************************
reply to a negprot
****************************************************************************/
@@ -2927,41 +2855,66 @@
int protocol;
char *p;
int bcc = SVAL(smb_buf(inbuf),-2);
- int arch_known = 0;
+ int arch = ARCH_ALL;
- /* look through the protocol list to determine architecture */
- Index = 0;
p = smb_buf(inbuf)+1;
while (p < (smb_buf(inbuf) + bcc))
{
- DEBUG(3,("protocol [%s]\n",p));
- if (!arch_known) {
- if (strcsequal(p,"Samba")) {
- strcpy(remote_arch,"Samba");
- arch_known = 1;
- } else if (strcsequal(p,"NT LM 0.12")) {
- strcpy(remote_arch,"WinNT");
- } else if (strcsequal(p,"Windows for Workgroups 3.1a")) {
- strcpy(remote_arch,"WfWg");
- }
- Index++;
+ Index++;
+ DEBUG(1,("Requested protocol [%s]\n",p));
+ if (strcsequal(p,"Windows for Workgroups 3.1a"))
+ arch &= ( ARCH_WFWG | ARCH_WIN95 | ARCH_WINNT );
+ else if (strcsequal(p,"DOS LM1.2X002"))
+ arch &= ( ARCH_WFWG | ARCH_WIN95 );
+ else if (strcsequal(p,"DOS LANMAN2.1"))
+ arch &= ( ARCH_WFWG | ARCH_WIN95 );
+ else if (strcsequal(p,"NT LM 0.12"))
+ arch &= ( ARCH_WIN95 | ARCH_WINNT );
+ else if (strcsequal(p,"LANMAN2.1"))
+ arch &= ( ARCH_WINNT | ARCH_OS2 );
+ else if (strcsequal(p,"LM1.2X002"))
+ arch &= ( ARCH_WINNT | ARCH_OS2 );
+ else if (strcsequal(p,"MICROSOFT NETWORKS 1.03"))
+ arch &= ARCH_WINNT;
+ else if (strcsequal(p,"XENIX CORE"))
+ arch &= ( ARCH_WINNT | ARCH_OS2 );
+ else if (strcsequal(p,"Samba")) {
+ arch = ARCH_SAMBA;
+ break;
}
+
p += strlen(p) + 2;
}
-
- DEBUG(4,("Got remote arch %s\n",remote_arch));
-
+
+ switch ( arch ) {
+ case ARCH_SAMBA:
+ strcpy(remote_arch,"Samba");
+ break;
+ case ARCH_WFWG:
+ strcpy(remote_arch,"WfWg");
+ break;
+ case ARCH_WIN95:
+ strcpy(remote_arch,"Win95");
+ break;
+ case ARCH_WINNT:
+ strcpy(remote_arch,"WinNT");
+ break;
+ case ARCH_OS2:
+ strcpy(remote_arch,"OS2");
+ break;
+ default:
+ strcpy(remote_arch,"UNKNOWN");
+ break;
+ }
+
/* possibly reload - change of architecture */
reload_services(True);
-
+
/* a special case to stop password server loops */
if (Index == 1 && strequal(remote_machine,myhostname) &&
lp_security()==SEC_SERVER)
exit_server("Password server loop!");
- /* check the log file size */
- check_log_size();
-
/* Check for protocols, most desirable first */
for (protocol = 0; supported_protocols[protocol].proto_name; protocol++)
{
@@ -2981,8 +2934,11 @@
SSVAL(outbuf,smb_vwv0,choice);
if(choice != -1) {
+ extern fstring remote_proto;
+ strcpy(remote_proto,supported_protocols[protocol].short_name);
+ reload_services(True);
outsize = supported_protocols[protocol].proto_reply_fn(outbuf);
- DEBUG(2,("Chose protocol %s\n",supported_protocols[protocol].proto_name));
+ DEBUG(1,("Selected protocol %s\n",supported_protocols[protocol].proto_name));
}
else {
DEBUG(0,("No protocol supported !\n"));
@@ -3340,8 +3296,7 @@
if (!firsttime) exit(0);
firsttime = 0;
- if (done_become_user != -1)
- unbecome_user();
+ unbecome_user();
DEBUG(1,("Closing connections\n"));
for (i=0;i<MAX_CONNECTIONS;i++)
if (Connections[i].open)
@@ -3585,7 +3540,7 @@
int uid = SVAL(inbuf,smb_uid);
/* does this protocol need to be run as root? */
- if (!(flags & AS_USER) && (done_become_user != -1))
+ if (!(flags & AS_USER))
unbecome_user();
/* does this protocol need to be run as the connected user? */
@@ -3814,6 +3769,8 @@
send_one_packet(OutBuffer,1,ip,137,SOCK_DGRAM);
}
#endif
+
+ last_user.cnum = -1;
while (True)
{
@@ -3834,8 +3791,7 @@
{
extern pstring share_del_pending;
if (*share_del_pending) {
- if (done_become_user != -1)
- unbecome_user();
+ unbecome_user();
if (!unlink(share_del_pending))
DEBUG(3,("Share file deleted %s\n",share_del_pending));
else
@@ -3845,8 +3801,7 @@
}
if (share_mode_pending) {
- if (done_become_user != -1)
- unbecome_user();
+ unbecome_user();
check_share_modes();
share_mode_pending=False;
}
@@ -3871,8 +3826,7 @@
t = time(NULL);
/* become root again if waiting */
- if (done_become_user != -1)
- unbecome_user();
+ unbecome_user();
/* check for smb.conf reload */
if (!(counter%SMBD_RELOAD_CHECK))
@@ -4016,6 +3970,7 @@
****************************************************************************/
int main(int argc,char *argv[])
{
+ extern BOOL append_log;
/* shall I run as a daemon */
BOOL is_daemon = False;
int port = 139;
@@ -4031,8 +3986,12 @@
set_auth_parameters(argc,argv);
#endif
+ append_log = True;
+
TimeInit();
+ strcpy(debugf,SMBLOGFILE);
+
setup_logging(argv[0],False);
charset_initialise();
@@ -4048,8 +4007,6 @@
seteuid(0);
#endif
- strcpy(debugf,SMBLOGFILE);
-
fault_setup(exit_server);
umask(0777 & ~DEF_CREATE_MASK);
@@ -4100,7 +4057,10 @@
strcpy(debugf,optarg);
break;
case 'a':
- append_log = !append_log;
+ {
+ extern BOOL append_log;
+ append_log = !append_log;
+ }
break;
case 'D':
is_daemon = True;
diff -u -r --new-file last-version/source/smb.h samba-1.9.15p6/source/smb.h
--- last-version/source/smb.h Sun Dec 3 19:23:44 1995
+++ samba-1.9.15p6/source/smb.h Mon Dec 4 11:47:31 1995
@@ -825,7 +825,6 @@
void expand_mask(char *Mask, BOOL);
BOOL sane_unix_date(time_t unixdate);
time_t start_of_month(void);
-void log_out(char *buffer,int len);
char *smb_fn_name(int cnum);
void get_machine_info(void);
int open_socket_in(int type, int port, int dlevel);
@@ -833,7 +832,6 @@
struct in_addr *interpret_addr2(char *str);
BOOL zero_ip(struct in_addr ip);
int read_max_udp(int fd,char *buffer,int bufsize,int maxtime);
-void log_in(char *buffer,int len);
int interpret_protocol(char *str,int def);
int interpret_security(char *str,int def);
int ChDir(char *path);
@@ -963,7 +961,8 @@
enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
/* printing types */
-enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX};
+enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,PRINT_QNX};
+
/* case handling */
enum case_handling {CASE_LOWER,CASE_UPPER};
diff -u -r --new-file last-version/source/util.c samba-1.9.15p6/source/util.c
--- last-version/source/util.c Sat Dec 2 19:36:08 1995
+++ samba-1.9.15p6/source/util.c Tue Dec 5 13:19:19 1995
@@ -37,8 +37,6 @@
/* these are some file handles where debug info will be stored */
FILE *dbf = NULL;
-FILE *login=NULL;
-FILE *logout=NULL;
/* the client file descriptor */
int Client = -1;
@@ -83,6 +81,7 @@
fstring remote_machine="";
fstring local_machine="";
fstring remote_arch="UNKNOWN";
+fstring remote_proto="UNKNOWN";
pstring myhostname="";
pstring user_socket_options="";
pstring sesssetup_user="";
@@ -111,6 +110,46 @@
}
}
+
+BOOL append_log=False;
+
+
+/****************************************************************************
+reopen the log files
+****************************************************************************/
+void reopen_logs(void)
+{
+ extern FILE *dbf;
+ pstring fname;
+
+ if (DEBUGLEVEL > 0)
+ {
+ strcpy(fname,debugf);
+ if (lp_loaded() && (*lp_logfile()))
+ strcpy(fname,lp_logfile());
+
+ if (!strcsequal(fname,debugf) || !dbf || !file_exist(debugf,NULL))
+ {
+ strcpy(debugf,fname);
+ if (dbf) fclose(dbf);
+ if (append_log)
+ dbf = fopen(debugf,"a");
+ else
+ dbf = fopen(debugf,"w");
+ if (dbf) setbuf(dbf,NULL);
+ }
+ }
+ else
+ {
+ if (dbf)
+ {
+ fclose(dbf);
+ dbf = NULL;
+ }
+ }
+}
+
+
/*******************************************************************
write an debug message on the debugfile. This is called by the DEBUG
macro
@@ -121,7 +160,7 @@
#else
int Debug1(va_alist)
va_dcl
-{
+{
char *format_str;
#endif
va_list ap;
@@ -139,50 +178,76 @@
return(0);
}
+ {
+ static int debug_count=0;
+
+ debug_count++;
+ if (debug_count == 100) {
+ int maxlog = lp_max_log_size() * 1024;
+ if (dbf && maxlog > 0)
+ {
+ struct stat st;
+
+ if (fstat(fileno(dbf),&st) == 0 && st.st_size > maxlog) {
+ fclose(dbf); dbf = NULL;
+ reopen_logs();
+ if (dbf && file_size(debugf) > maxlog) {
+ pstring name;
+ fclose(dbf); dbf = NULL;
+ sprintf(name,"%s.old",debugf);
+ sys_rename(debugf,name);
+ reopen_logs();
+ }
+ }
+ }
+ debug_count=0;
+ }
+ }
+
#ifdef SYSLOG
if (!lp_syslog_only())
#endif
- {
- if (!dbf)
- {
+ {
+ if (!dbf)
+ {
dbf = fopen(debugf,"w");
if (dbf)
setbuf(dbf,NULL);
else
return(0);
- }
- }
+ }
+ }
#ifdef SYSLOG
if (syslog_level < lp_syslog())
- {
- /*
- * map debug levels to syslog() priorities
- * note that not all DEBUG(0, ...) calls are
- * necessarily errors
- */
- static int priority_map[] = {
- LOG_ERR, /* 0 */
- LOG_WARNING, /* 1 */
- LOG_NOTICE, /* 2 */
- LOG_INFO, /* 3 */
- };
- int priority;
- pstring msgbuf;
-
- if (syslog_level >= sizeof(priority_map) / sizeof(priority_map[0]) ||
- syslog_level < 0)
- priority = LOG_DEBUG;
- else
- priority = priority_map[syslog_level];
-
- vsprintf(msgbuf, format_str, ap);
-
- msgbuf[255] = '\0';
- syslog(priority, "%s", msgbuf);
- }
+ {
+ /*
+ * map debug levels to syslog() priorities
+ * note that not all DEBUG(0, ...) calls are
+ * necessarily errors
+ */
+ static int priority_map[] = {
+ LOG_ERR, /* 0 */
+ LOG_WARNING, /* 1 */
+ LOG_NOTICE, /* 2 */
+ LOG_INFO, /* 3 */
+ };
+ int priority;
+ pstring msgbuf;
+
+ if (syslog_level >= sizeof(priority_map) / sizeof(priority_map[0]) ||
+ syslog_level < 0)
+ priority = LOG_DEBUG;
+ else
+ priority = priority_map[syslog_level];
+
+ vsprintf(msgbuf, format_str, ap);
+
+ msgbuf[255] = '\0';
+ syslog(priority, "%s", msgbuf);
+ }
#endif
-
+
#ifdef SYSLOG
if (!lp_syslog_only())
#endif
@@ -190,7 +255,7 @@
vfprintf(dbf,format_str,ap);
fflush(dbf);
}
-
+
va_end(ap);
return(0);
}
@@ -1950,35 +2015,6 @@
}
-/****************************************************************************
-log a packet to logout
-****************************************************************************/
-void log_out(char *buffer,int len)
-{
- if (DEBUGLEVEL > 100 && logout)
- {
- fprintf(logout,"\n%s Transaction %d (%d)\n",timestring(),trans_num++,len);
- fwrite(buffer,len,1,logout);
- fflush(logout);
- }
- DEBUG(7,("logged %d bytes out\n",len));
-}
-
-/****************************************************************************
-log a packet to login
-****************************************************************************/
-void log_in(char *buffer,int len)
-{
- if (DEBUGLEVEL > 100 && login)
- {
- fprintf(login,"\n%s Transaction %d (%d)\n",timestring(),trans_num++,len);
- fwrite(buffer,len,1,login);
- fflush(login);
- }
- DEBUG(7,("logged %d bytes in\n",len));
-}
-
-
/*******************************************************************
close the low 3 fd's and open dev/null in their place
********************************************************************/
@@ -2595,7 +2631,6 @@
exit(1);
}
- log_in(buffer,len+4);
return(True);
}
@@ -2609,8 +2644,6 @@
int ret,nwritten=0;
len = smb_len(buffer) + 4;
- log_out(buffer,len);
-
while (nwritten < len)
{
ret = write_socket(fd,buffer+nwritten,len - nwritten);
@@ -2701,9 +2734,6 @@
sock_out.sin_port = htons( port );
sock_out.sin_family = AF_INET;
- /* log the packet */
- log_out(buf,len);
-
if (DEBUGLEVEL > 0)
DEBUG(3,("sending a packet of len %d to (%s) on port %d of type %s\n",
len,inet_ntoa(ip),port,type==SOCK_DGRAM?"DGRAM":"STREAM"));
@@ -3858,6 +3888,7 @@
{
if (!strchr(s,'%')) return;
+ string_sub(s,"%R",remote_proto);
string_sub(s,"%a",remote_arch);
string_sub(s,"%m",remote_machine);
string_sub(s,"%L",local_machine);
diff -u -r --new-file last-version/source/version.h samba-1.9.15p6/source/version.h
--- last-version/source/version.h Sun Dec 3 22:13:02 1995
+++ samba-1.9.15p6/source/version.h Tue Dec 5 16:00:09 1995
@@ -1 +1 @@
-#define VERSION "1.9.15p5"
+#define VERSION "1.9.15p6"